package com.reins.bookstore.repository;

import com.reins.bookstore.entity.Basketline;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BasketlineRepository extends JpaRepository<Basketline,Integer> {

    @Query(value = "select * from Basketline where user_id = :id ",nativeQuery = true)
    List<Basketline> findAllBasketlinesByUserId(Integer id);

    @Query(value = "select * from Basketline where user_id =:userId and book_id =:bookId",nativeQuery = true)
    Basketline checkBasketline(Integer userId, Integer bookId);

    @Query(value = "delete * from Basketline where user_id =:userId", nativeQuery = true)
    List<Basketline> deleteAllByUserId(Integer userId);
}
